Ext.define('SKJF.view.PEMBELIAN.v_po_form', {
	extend	: 'Ext.form.Panel',
	
	alias	: 'widget.v_po_form',
	
	//region:'east',
	//id: 'east-region-container',
	
	title		: 'Create/Update po',
    bodyPadding	: 5,
    autoScroll	: true,
    
    initComponent: function(){
    	/*
		 * Deklarasi variable setiap field
		 */
		 
		 var mstcurrency_store = Ext.create('SKJF.store.s_mstcurrency',{autoLoad:true});
		 var mstsupplier_store = Ext.create('SKJF.store.s_mstsupplier');
		 var LOKAL_IMPORT_store = Ext.create('Ext.data.Store', {
			fields: ['value', 'display'],
			data : [{"value":"LOKAL", "display":"LOKAL"},{"value":"IMPORT", "display":"IMPORT"}]
		});
		
		mstsupplier_store.load();
		 
		var NOMOR_PO_field = Ext.create('Ext.form.field.Text', {
			itemId: 'NOMOR_PO_field',
			name: 'NOMOR_PO', /* column name of table */
			fieldLabel: 'NOMOR_PO',
			allowBlank: true /* jika primary_key */,
			readOnly:true
		});
		var TANGGAL_PO_field = Ext.create('Ext.form.field.Date', {
			name: 'TANGGAL_PO', /* column name of table */
			format: 'Y-m-d',
			fieldLabel: 'TANGGAL_PO',
			value: new Date()
		});
		var NAMA_SUPPLIER_field = Ext.create('Ext.form.field.ComboBox', {
			itemId: 'NAMA_SUPPLIER_field',
			name: 'NAMA_SUPPLIER', /* column name of table */
			fieldLabel: 'NAMA_SUPPLIER',
			pageSize: 10,
			typeAhead    : true,
			triggerAction: 'all',
			selectOnFocus: true,
            loadingText  : 'Searching...',
			store: mstsupplier_store,
			queryMode: 'local',
			tpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'<div class="x-boundlist-item">{NAMA_SUPPLIER} - {TELPON}</div>',
				'</tpl>'
			),
			displayTpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'{NAMA_SUPPLIER} - {TELPON}',
				'</tpl>'
			),
			valueField: 'NAMA_SUPPLIER',
			displayField: 'NAMA_SUPPLIER'
			
		});
		
		var TARGET_BRG_DATANG_field = Ext.create('Ext.form.field.Date', {
			name: 'TARGET_BRG_DATANG', /* column name of table */
			format: 'Y-m-d',
			fieldLabel: 'TARGET_BRG_DATANG'
		});
		var LOKAL_IMPORT_field = Ext.create('Ext.form.field.ComboBox', {
			name: 'LOKAL_IMPORT', /* column name of table */
			fieldLabel: 'LOKAL_IMPORT',
			store: LOKAL_IMPORT_store,
			queryMode: 'local',
			displayField: 'display',
			valueField: 'value'
		});
		
		var BANKER_field = Ext.create('Ext.form.field.Text', {
			name: 'BANKER', /* column name of table */
			fieldLabel: 'BANKER',
			maxLength: 50 /* length of column name */
		});
		var IMPORTER_field = Ext.create('Ext.form.field.Text', {
			name: 'IMPORTER', /* column name of table */
			fieldLabel: 'IMPORTER',
			maxLength: 50 /* length of column name */
		});
		var ALAMAT_IMPORTER_field = Ext.create('Ext.form.field.Text', {
			name: 'ALAMAT_IMPORTER', /* column name of table */
			fieldLabel: 'ALAMAT_IMPORTER',
			maxLength: 50 /* length of column name */
		});
		var PACKING_field = Ext.create('Ext.form.field.Text', {
			name: 'PACKING', /* column name of table */
			fieldLabel: 'PACKING',
			maxLength: 30 /* length of column name */
		});
		var SHIPMENT_field = Ext.create('Ext.form.field.Text', {
			name: 'SHIPMENT', /* column name of table */
			fieldLabel: 'SHIPMENT',
			maxLength: 50 /* length of column name */
		});
		var LOADING_PORT_field = Ext.create('Ext.form.field.Text', {
			name: 'LOADING_PORT', /* column name of table */
			fieldLabel: 'LOADING_PORT',
			maxLength: 50 /* length of column name */
		});
		var DEST_PORT_field = Ext.create('Ext.form.field.Text', {
			name: 'DEST_PORT', /* column name of table */
			fieldLabel: 'DEST_PORT',
			maxLength: 50 /* length of column name */
		});
		var OTHER_COND_field = Ext.create('Ext.form.field.Text', {
			name: 'OTHER_COND', /* column name of table */
			fieldLabel: 'OTHER_COND',
			maxLength: 50 /* length of column name */
		});
		var CURRENCY_field = Ext.create('Ext.form.field.ComboBox', {
			name: 'CURRENCY', /* column name of table */
			fieldLabel: 'CURRENCY',
			pageSize: 10,
			typeAhead    : true,
			triggerAction: 'all',
			selectOnFocus: true,
            loadingText  : 'Searching...',
			store: mstcurrency_store,
			queryMode: 'local',
			tpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'<div class="x-boundlist-item">{CURRENCY} - {NEGARA}</div>',
				'</tpl>'
			),
			displayTpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'{CURRENCY}',
				'</tpl>'
			),
			valueField: 'CURRENCY',
			displayField: 'CURRENCY'
		});
		var KURS_field = Ext.create('Ext.form.field.Number', {
			name: 'KURS', /* column name of table */
			fieldLabel: 'KURS',
			maxLength: 11 /* length of column name */
		});
		var KETERANGAN_field = Ext.create('Ext.form.field.Text', {
			name: 'KETERANGAN', /* column name of table */
			fieldLabel: 'KETERANGAN',
			maxLength: 50 /* length of column name */
		});
		var DIPESAN_OLEH_field = Ext.create('Ext.form.field.Text', {
			name: 'DIPESAN_OLEH', /* column name of table */
			fieldLabel: 'DIPESAN_OLEH',
			maxLength: 30 /* length of column name */
		});
		var DISETUJUI_OLEH_field = Ext.create('Ext.form.field.Text', {
			name: 'DISETUJUI_OLEH', /* column name of table */
			fieldLabel: 'DISETUJUI_OLEH',
			maxLength: 30 /* length of column name */
		});
		var FLAG_field = Ext.create('Ext.form.field.Hidden', {
			name: 'FLAG', /* column name of table */
			fieldLabel: 'FLAG',
			maxLength: 1 /* length of column name */
		});		
        Ext.apply(this, {
            fieldDefaults: {
                labelAlign: 'right',
                labelWidth: 120,
                msgTarget: 'qtip',
				anchor: '100%'
            },
			defaultType: 'textfield',
            items: [NOMOR_PO_field,TANGGAL_PO_field,NAMA_SUPPLIER_field,TARGET_BRG_DATANG_field,LOKAL_IMPORT_field,BANKER_field,IMPORTER_field,ALAMAT_IMPORTER_field,PACKING_field,SHIPMENT_field,LOADING_PORT_field,DEST_PORT_field,OTHER_COND_field,CURRENCY_field,KURS_field,KETERANGAN_field,DIPESAN_OLEH_field,DISETUJUI_OLEH_field,FLAG_field],
			
	        buttons: [{
                iconCls: 'icon-save',
                itemId: 'save',
                text: 'Save',
                disabled: true,
                action: 'save'
            }, {
                iconCls: 'icon-add',
				itemId: 'create',
                text: 'Create',
                action: 'create'
            }, {
                iconCls: 'icon-reset',
                text: 'Cancel',
                action: 'cancel'
            }]
        });
        
        this.callParent();
    }
});